﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PSLib.CodeFormating.Lexems
{
	/// <summary>
	/// Class wich represent single lexem.
	/// </summary>
	public class Lexem
	{
		internal Lexem()
		{
			Reset();
		}

		/// <summary>
		/// Lexem source
		/// </summary>
		public string LexemSource { get; set; }

		/// <summary>
		/// Current lexem type
		/// </summary>
		public LexemType Type 
		{
			get { return this.CustomType != null ? LexemType.Custom : type; }
			set { type = value; }
		}

		/// <summary>
		/// Current lexem custom type
		/// </summary>
		public LexemCustomType CustomType { get; set; }

		/// <summary>
		/// Function for cloning lexem
		/// </summary>
		/// <returns>New lexem.</returns>
		public Lexem Clone()
		{
			return new Lexem { LexemSource = this.LexemSource, Type = this.Type };
		}

		public void Reset()
		{
			this.Type = LexemType.None;
			this.LexemSource = string.Empty;
		}

		public override string ToString()
		{
			return string.Format("CE({0}): {1}",this.Type,this.LexemSource);
		}

		private LexemType type;
	}
}
